package ch.zbw.sysventory.server.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import ch.zbw.sysventory.server.model.Computer;
import ch.zbw.sysventory.server.repository.ComputerRepository;
import ch.zbw.sysventory.server.service.ComputerService;

@Service
public class ComputerServiceImpl implements ComputerService {

	@Autowired(required = true)
	private ComputerRepository computerRepository;

	@Override
	public Computer get(Long id) {
		return this.computerRepository.findOne(id);
	}

	@Override
	public List<Computer> list() {
		return this.computerRepository.findAll();
	}

	@Override
	public Computer createNewComputer() {
		return this.computerRepository.saveAndFlush(new Computer());
	}

}
